package com.example.week3;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private EditText editText1;
    private EditText editText2;
    private Button button;

    //private LinearLayout myLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        editText1 =(EditText) findViewById(R.id.shu1);
        editText2 =(EditText) findViewById(R.id.shu2);
        button = (Button)findViewById(R.id.deng);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s;
                String t;
                s="201958501330";
                t="123456";
                if(s.equals(editText1.getText().toString())==false)  {
                    Toast.makeText(MainActivity.this, editText1.getText().toString(),Toast.LENGTH_LONG).show();
                }else{
                    if(t.equals(editText2.getText().toString())==false)  {
                        Toast.makeText(MainActivity.this, "密码错误...",Toast.LENGTH_LONG).show();
                    }else{
                        button.setBackgroundColor(Color.CYAN);
                        Bundle bundle = new Bundle();
                        bundle.putInt("num",1);
                        bundle.putString("msg", editText1.getText().toString());
                        //新② 创建 Intent 对象，向 Intent 对象添加数据
                        Intent intent =new Intent(MainActivity.this, Main2Activity.class);
                        intent.putExtras(bundle);
                        //新③ 用 startActivity()方法启动新的 Activity
                        startActivity(intent);

                    }
                }
            }
        });

    }
}
